Skip to content

fix(validate): only recommend 512x512 icon size when the icon isn't already 512x512#248

Open
adityasingh2400 wants to merge 1 commit into
modelcontextprotocol:mainfrom
adityasingh2400:fix/icon-size-warning-only-when-not-512
Open

fix(validate): only recommend 512x512 icon size when the icon isn't already 512x512#248
adityasingh2400 wants to merge 1 commit into
modelcontextprotocol:mainfrom
adityasingh2400:fix/icon-size-warning-only-when-not-512

Conversation

@adityasingh2400
Copy link
Copy Markdown

Problem

mcpb validate prints the "Recommended size is 512×512 pixels" message for every valid PNG icon, even when the icon is already 512×512. This is #218, which a maintainer confirmed: the icon check verifies the PNG signature bytes but never reads the image dimensions, so the recommendation is unconditional.

Before:

Icon validation warnings:

  - Icon validation passed. Recommended size is 512×512 pixels for best display in Claude Desktop.

(printed regardless of the icon's real size, including for a correct 512×512 icon)

Fix

Read the width and height from the PNG IHDR chunk and only emit the recommendation when the icon is not already 512×512. The warning now also reports the icon's actual dimensions so authors know what to change:

Icon validation warnings:

  - Icon is 256×256 pixels. Recommended size is 512×512 pixels for best display in Claude Desktop.

A correctly-sized 512×512 icon produces no icon warning at all.

The IHDR chunk is required by the PNG spec to be the first chunk immediately after the 8-byte signature, so width/height live at fixed offsets (16 and 20). getPNGDimensions returns null if the buffer is too short or those bytes are not an IHDR chunk, in which case the recommendation is simply skipped rather than guessed.

Testing

  • yarn test — all 8 suites, 126 tests pass.
  • yarn lint — clean.
  • Updated test/icon-validation.test.ts: the existing local-icon fixture is 1×1, so it now asserts the recommendation appears with the real dimensions; added a 512×512 fixture asserting no recommendation is shown.
  • Verified manually against real zlib-encoded PNGs: a 512×512 icon passes with no size warning, a 256×256 icon reports Icon is 256×256 pixels.

Fixes #218

mcpb validate always printed the 512x512 size recommendation for any
valid PNG icon, because the icon check verified the PNG signature but
never read the actual image dimensions. A correctly-sized 512x512 icon
still got told to be 512x512.

Read the width and height from the PNG IHDR chunk and only emit the
recommendation when the icon is not already 512x512. The warning now
also reports the icon's actual dimensions so authors know what to fix.

Fixes modelcontextprotocol#218
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] mcpb validate warns about icon size even for 512x512 PNGs

1 participant